#pragma once

#include "HiPicShare.h"
#include "RTPDecoderHandle.hpp"

class SharedMemory;
class RTPSharePictureImpl {
  public:
    ~RTPSharePictureImpl();

  public:
    bool Start(const char *sharePathPrefix, uint32_t width, uint32_t height);
    void Stop();

  public:
    void OnYUV(const uint8_t *data, size_t len, uint32_t width, uint32_t height,
               void *option);
    void OnRGB(const uint8_t *data, size_t len, uint32_t width, uint32_t height,
               void *option);

  private:
    SharedMemory *CreateYUVShareMemory(const char *sharePath, uint32_t width,
                                       uint32_t height);
    SharedMemory *CreateBGRShareMemory(const char *sharePath, uint32_t width,
                                       uint32_t height);

  private:
    inline static uint32_t GetYUVSize(uint32_t width, uint32_t height) {
        return width * height * 3 / 2;
    }
    inline static uint32_t GetBGRSize(uint32_t width, uint32_t height) {
        return width * height * 3;
    }

  private:
    SharedMemory *yuvMemory{nullptr};
    SharedMemory *bgrMemory{nullptr};

    HiPicShare bgrShareProxy;
    HiPicShare yuvShareProxy;
};